import request from '@/utils/request.js'
//提供调用注册接口的函数
export const userRegisterAService=(requestBody)=>{
    return request.post('/users/registerA',requestBody);
}
export const userRegisterBService=(requestBody)=>{
    return request.post('/users/registerB',requestBody);
}
//提供调用登录接口的函数
export const userLoginService=(loginDate)=>{
    return request.post('/users/login',loginDate);
}
export const sysLoginService=(username,password,authCode)=>{
    const params = new URLSearchParams();
    params.append("username", username);
    params.append("password", password);
    params.append("authCode", authCode);
    return request.post('/users/sLogin',params);
}
export const userUpdateName = (userId, userName) => {
    const formData = new FormData();
    formData.append('userName', userName);
    return request.patch('/users/updateName', formData, {
        headers: { 'user-info': userId }
    });
};

export const userExist = (userId) => {
    return request.post('/users/userExist', null, {
        headers: { 'user-info': userId }
    });
};
export const userUpdatePass = (userId, oldPass,password) => {
    const formData = new FormData();
    formData.append('userName', oldPass);
    formData.append('password', password);
    return request.patch('/users/updatePass', formData, {
        headers: { 'user-info': userId }
    });
};

export const updateInfoByIdService = (userId,job, status) => {
    const formData = new FormData();
    formData.append('status', status);
    formData.append('job', job);
    formData.append('userId', userId);
    return request.put('/users/updateStatus', formData);
};
export const userGetCanUser = (enterpriseId,pageNo,pageSize) => {
    return request.get('/users/getCanUsers', {
        params: {
            enterpriseId : enterpriseId,
            pageNo,
            pageSize
        }
    });
};
export const getCanNums = (enterpriseId) => {
    return request.get('/users/getCanNums', {
        params: { enterpriseId }
    });
};
export const userGetUser = (enterpriseId, phone, name, pageNo, pageSize) => {
    return request.get('/users/queryUsersPage', {
        params: {
            enterpriseId: enterpriseId,
            phone: phone,
            name: name,
            pageNo,
            pageSize
        }
    });
};
export const getSysUserInfo = (id) => {
    return request.get('/users/getSysUser', {
        params: { id }
    });
};
export const getJobs = (enterpriseId) => {
    return request.get('/users/getJobs', {
        params: { enterpriseId }
    });
};
export const getJobUsers = (enterpriseId,approveType) => {
    return request.get('/users/getJobUsers', {
        params: { enterpriseId,approveType }
    });
};

export const getUserName = (id) => {
    return request.get('/users/getUserName', {
        params: { id }
    });
};
export const userUpdateEmail = (userId,oldCode, newEmail,eCode) => {
    const formData = new FormData();
    formData.append('newEmail', newEmail);
    formData.append('userId', userId);
    formData.append('eCode', eCode);
    formData.append('oldCode', oldCode);
    return request.patch('/users/updatePass', formData, {
        headers: { 'user-info': userId }
    });
};

